
/*
 * Copyright (C) 2024 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "bluetooth_a2dp_impl.h"

#include "bluetooth_a2dp_src.h"
#include "bluetooth_errorcode.h"
#include "bluetooth_impl_utils.h"
#include "bluetooth_jni.h"
#include "bluetooth_log.h"

using namespace OHOS::bluetooth;
namespace OHOS {
namespace Bluetooth {

BluetoothA2DPImpl::BluetoothA2DPImpl() {}
BluetoothA2DPImpl::~BluetoothA2DPImpl() {}

int BluetoothA2DPImpl::Connect(const RawAddress& device)
{
    return 0;
}

int BluetoothA2DPImpl::Disconnect(const RawAddress& device)
{
    return 0;
}

void BluetoothA2DPImpl::RegisterObserver(const sptr<IBluetoothA2dpSourceObserver>& observer)
{
    observer_ = observer;
}

void BluetoothA2DPImpl::DeregisterObserver(const sptr<IBluetoothA2dpSourceObserver>& observer)
{
    observer_ = nullptr;
}

int BluetoothA2DPImpl::GetDevicesByStates(const std::vector<int32_t>& states, std::vector<RawAddress>& rawAddrs)
{
    return BluetoothJni::GetDevicesByStates(states, rawAddrs);
}

int BluetoothA2DPImpl::GetDeviceState(const RawAddress& device, int& state)
{
    return BluetoothJni::GetConnectionState(device, state);
}

int BluetoothA2DPImpl::GetPlayingState(const RawAddress& device, int& state)
{
    return 0;
}

int BluetoothA2DPImpl::SetConnectStrategy(const RawAddress& device, int32_t strategy)
{
    return 0;
}

int BluetoothA2DPImpl::GetConnectStrategy(const RawAddress& device, int& strategy)
{
    return 0;
}

int BluetoothA2DPImpl::SetActiveSinkDevice(const RawAddress& device)
{
    return 0;
}

RawAddress BluetoothA2DPImpl::GetActiveSinkDevice()
{
    RawAddress ret;
    return ret;
}

BluetoothA2dpCodecStatus BluetoothA2DPImpl::GetCodecStatus(const RawAddress& device)
{
    BluetoothA2dpCodecStatus ret;
    return ret;
}

int BluetoothA2DPImpl::GetCodecPreference(const RawAddress& device, BluetoothA2dpCodecInfo& info)
{
    return 0;
}

int BluetoothA2DPImpl::SetCodecPreference(const RawAddress& device, const BluetoothA2dpCodecInfo& info)
{
    return 0;
}

void BluetoothA2DPImpl::SwitchOptionalCodecs(const RawAddress& device, bool isEnable) {}

int BluetoothA2DPImpl::GetOptionalCodecsSupportState(const RawAddress& device)
{
    return 0;
}

int BluetoothA2DPImpl::StartPlaying(const RawAddress& device)
{
    return 0;
}

int BluetoothA2DPImpl::SuspendPlaying(const RawAddress& device)
{
    return 0;
}

int BluetoothA2DPImpl::StopPlaying(const RawAddress& device)
{
    return 0;
}

int BluetoothA2DPImpl::WriteFrame(const uint8_t* data, uint32_t size)
{
    return 0;
}

int BluetoothA2DPImpl::GetRenderPosition(
    const RawAddress& device, uint32_t& delayValue, uint64_t& sendDataSize, uint32_t& timeStamp)
{
    return 0;
}

int BluetoothA2DPImpl::OffloadStartPlaying(const RawAddress& device, const std::vector<int32_t>& sessionsId)
{
    return 0;
}

int BluetoothA2DPImpl::OffloadStopPlaying(const RawAddress& device, const std::vector<int32_t>& sessionsId)
{
    return 0;
}

int BluetoothA2DPImpl::A2dpOffloadSessionPathRequest(
    const RawAddress& device, const std::vector<BluetoothA2dpStreamInfo>& info)
{
    return 0;
}

BluetoothA2dpOffloadCodecStatus BluetoothA2DPImpl::GetOffloadCodecStatus(const RawAddress& device)
{
    BluetoothA2dpOffloadCodecStatus ret;
    return ret;
}

int BluetoothA2DPImpl::EnableAutoPlay(const RawAddress& device)
{
    return 0;
}

int BluetoothA2DPImpl::DisableAutoPlay(const RawAddress& device, const int duration)
{
    return 0;
}

int BluetoothA2DPImpl::GetAutoPlayDisabledDuration(const RawAddress& device, int& duration)
{
    return 0;
}

int BluetoothA2DPImpl::OnConnectionStateChanged(const RawAddress& device, int state, int cause)
{
    std::lock_guard<std::mutex> lock(observerMutex_);
    if (observer_ == nullptr) {
        HILOGE("observer_ is null");
        return BT_ERR_INTERNAL_ERROR;
    }

    cause = static_cast<int>(ConnChangeCause::CONNECT_CHANGE_COMMON_CAUSE);
    observer_->OnConnectionStateChanged(device, state, cause);
    return BT_NO_ERROR;
}

void BluetoothA2DPImpl::GetVirtualDeviceList(std::vector<std::string>& devices) {}

void BluetoothA2DPImpl::UpdateVirtualDevice(int32_t action, const std::string& address) {}
} // namespace Bluetooth
} // namespace OHOS
